PROJECTENGRAM

NAME

Name

Tags: #◇CCPROG2 #◇C Programming #◇Programming #◇Computer Science #◇Data Structures #◇Data Types #◇Structured Programming #◇Memory Management


◇Overview

The array name is an identifier that refers to the entire array and acts as a pointer to the first element.

◇Key Concepts

Follows C identifier naming rules Array name decays to a pointer to the first element in most contexts Cannot be reassigned (it’s not a modifiable lvalue) Used to pass arrays to functions

◇Details / Theory

Naming Rules

Array names follow standard C identifier rules:
Can contain letters, digits, and underscores Must start with a letter or underscore Case-sensitive (arr ≠ Arr) Cannot be a C keyword

『』
C
int studentScores[50];   // Descriptive name
float x[10];             // Short name (acceptable for temp use)

Array Name as Pointer

In most expressions, the array name decays to a pointer to its first element:

『』
C
int arr[5] = {10, 20, 30, 40, 50};
int *p = arr;       // arr decays to &arr[0]
printf("%d", *p);   // Output: 10

Exceptions (No Decay)

The array name does NOT decay in these contexts:

  1. sizeof(arr) — returns total array size, not pointer size
  2. &arr — gives address of the whole array (type int (*)[5])

Cannot Reassign

『』
C
int arr[5], other[5];
arr = other;  // ERROR: array name is not assignable

◇Common Pitfalls

Thinking the array name IS a pointer variable — it’s a fixed address, not a modifiable pointer. Confusing sizeof(arr) (total size) with sizeof(ptr) (pointer size, typically 8 bytes).

◇Summary

TL;DR — The array name is an identifier that decays to a pointer to the first element in most contexts. It cannot be reassigned and follows standard C naming rules.

Related: ◇Declaration — ◇Arrays and Pointers — ◇Accessing Elements — ◇Arrays and Functions Source / Reference:

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

What does the array name represent when passed to a function?

Q2

Which of the following is an invalid array name in C?

Q3

Why can't you assign a new array directly to an array name using the = operator (e.g., arr = newArr;)?

Name | PROJECT ENGRAM